package wec_wallet.ebo.com.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import java.util.List;

import wec_wallet.ebo.com.R;
import wec_wallet.ebo.com.bean.Coin;

/**
 * Created by Administrator on 2018/3/27.
 */

public class TurnOutSubjectAdapter  extends ArrayAdapter<Coin> {
    private Context mContext;
    private List<Coin> mStringArray;

    public TurnOutSubjectAdapter(Context context, List<Coin> stringArray) {

// 注意：此处使用了系统默认item样式，所以getDropDownView和getView函数中TextView控件必须使用系统默认的text1名称

        super(context,android.R.layout.simple_spinner_item, stringArray);
        mContext = context;
        mStringArray = stringArray;
    }

    @Override
    public View getDropDownView(int position, View convertView, ViewGroup parent) {
// 修改Spinner下拉字体颜色
        if (convertView == null) {
            LayoutInflater inflater = LayoutInflater.from(mContext);
            convertView = inflater.inflate(R.layout.item_subject, parent, false);
        }
        TextView textView = convertView.findViewById(R.id.item_name);
        textView.setText(mStringArray.get(position).getWallet_name());
//// 注意：text1是系统默认Spinner用来显示文字的TextView控件名称，不可以修改
//        TextView txtvwDropdown = (TextView) convertView.findViewById(android.R.id.text1);
//        txtvwDropdown.setText(mStringArray.get(position));
//        txtvwDropdown.setTextSize(12f);
//        txtvwDropdown.setTextColor(Color.RED);
//        txtvwDropdown.setBackgroundColor(Color.GREEN);

        return convertView;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
// 修改Spinner显示字体颜色
        if (convertView == null) {
            LayoutInflater inflater = LayoutInflater.from(mContext);
            convertView = inflater.inflate(R.layout.spinner_display_style, parent, false);
        }

//注意：text1是系统默认Spinner用来显示文字的TextView控件名称，不可以修改
        TextView txtvwDisplay = (TextView) convertView.findViewById(R.id.txtvwSpinner);
        txtvwDisplay.setText(mStringArray.get(position).getWallet_name());
//        txtvwDisplay.setTextSize(16f);
//        txtvwDisplay.setTextColor(Color.WHITE);

        return convertView;
    }
}


